const express = require('express');
const router = express.Router();
// 引进mockjs
const Mock = require('mockjs');

// 监听路由
router.get('/list', (req, res) => {
    // 准备随机数据
    var data = {
        code: 0,
        success: true,
        data: Mock.mock({
            'list|10': [
                {
                    // 商品Id
                    'goodsId|+1': 1,
                    //商品名称
                    goodsName: '@ctitle(10)',
                    //商品地址
                    goodsAddress: '@county(true)',
                    //商品等级评价★
                    'goodsStar|1-5': '★',
                    //商品图片
                    goodsImg: "@Image('300x100','@color','image')",
                    //商品售价
                    'goodsSale|30-500': 30,
                },
            ],
            total: 30,
        }),
    };
    res.end(JSON.stringify(data));
});

module.exports = router;
